package com.tszs.Controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tszs.bean.DetailedCommodityFigures;
import com.tszs.biz.CommodityListBiz;
import com.tszs.biz.PersonalOrderBiz;
import com.tszs.entity.CommodityList;
import com.tszs.entity.PersonalOrder;
import com.tszs.util.CallBack;
/**
 * @类名：comprehensiveStatisticsController
 * @类描述：综合统计
 * @data：2019-03-30 17:10:50
 * @author 王俊
 *
 */
@Controller
public class comprehensiveStatisticsController {
	/**
	 * @CommodityListBiz
	 */
	@Autowired
	private CommodityListBiz commodityListBiz;
	/**
	 * @PersonalOrderBiz
	 */
	@Autowired
	private PersonalOrderBiz personalOrderBiz;
	/**
	 * @类名：QueryAllGoods
	 * @类描述：查询所有商品
	 * @data：2019-03-30 17:10:50
	 * @author 王俊
	 *
	 */
	@RequestMapping("pc/admin/QueryAllGoods")
	public void QueryAllGoods(HttpServletRequest request,HttpServletResponse response) {
		CommodityList example=new CommodityList();
		List<CommodityList> selectAall=commodityListBiz.selectAall(example);
		if(selectAall.size()>0) {
			new CallBack().yes(response, selectAall, "");
		}else {
			new CallBack().no(response, selectAall, "");
		}
	}
	/**
	 * @类名：findcomprehensiveStatistics
	 * @类描述：查询商品销售情况
	 * @data：2019-03-30 17:10:50
	 * @author 王俊
	 *
	 */
	@RequestMapping("pc/admin/findcomprehensiveStatistics")
	public void findcomprehensiveStatistics(HttpServletRequest request,HttpServletResponse response) {
		/*cName:cName,//商品ID
		cNames:cNames,//商品名称
		type3:type3,//开始时间
		type4:type4//结束时间
		 */	
		String begin=request.getParameter("type3");
		String end=request.getParameter("type4");
		PersonalOrder example=new PersonalOrder();
		if (!(null == begin) && !(null == end)) {
			if (!"".equals(begin) && !"".equals(end)) {
				begin = begin + " 00:00:01";
				end = end + " 23:59:59";
				example.setBegin(begin);
				example.setEnd(end);
			}
		}
		example.setProductId(request.getParameter("cName"));//去订单表根据ID去找是已支付，然后返回购买数量
		List<PersonalOrder> findProductNum=personalOrderBiz.findProductNum(example);
		String cNames=request.getParameter("cNames");
		List<String> list=new ArrayList<>();
		list.add(cNames);
		Map<String, Object>map=new HashMap<>();
		map.put("list", list);
		List<DetailedCommodityFigures> list2=new ArrayList<>();
		DetailedCommodityFigures detailedCommodityFigures=new DetailedCommodityFigures();
		detailedCommodityFigures.setName(cNames);
		detailedCommodityFigures.setValue(findProductNum.get(0).getProductNum());
		list2.add(detailedCommodityFigures);
		map.put("list2",list2);
		new CallBack().yes(response, map, "");
	}
}

